Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: chacha20 #51

Merged
merged 6 commits into from
Nov 22, 2024
Merged

feat: chacha20 #51

merged 6 commits into from
Nov 22, 2024

Conversation

0xJepsen
Copy link
Contributor

@0xJepsen 0xJepsen commented Nov 19, 2024

Reverts #50

Closes #54
This one is reopen so now you can review

@0xJepsen 0xJepsen requested review from lonerapier and Autoparallel and removed request for lonerapier November 19, 2024 16:05
@Autoparallel
Copy link
Contributor

lol the name here

@Autoparallel Autoparallel changed the title Revert "Revert "Chacha20"" feat: foldable chacha20 Nov 19, 2024
Copy link
Contributor

@Autoparallel Autoparallel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some changes requested here. Mostly to not remove AES.

builds/target_1024b/aes_gctr_nivc_1024b.circom Outdated Show resolved Hide resolved
builds/target_512b/aes_gctr_nivc_512b.circom Outdated Show resolved Hide resolved
circuits/chacha20/chacha20.circom Outdated Show resolved Hide resolved
circuits/chacha20/chacha-qr.circom Show resolved Hide resolved
circuits/chacha20/nivc/chacha20_nivc.circom Show resolved Hide resolved
circuits/test/chacha20/chacha20-nivc.test.ts Outdated Show resolved Hide resolved
circuits/test/chacha20/chacha20-nivc.test.ts Show resolved Hide resolved
circuits/test/full/full.test.ts Show resolved Hide resolved
circuits/utils/generics-bits.circom Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@Autoparallel Autoparallel added the performance ⚡️ This will not be worked on label Nov 19, 2024
@0xJepsen 0xJepsen force-pushed the revert-50-revert-49-chacha20 branch from f0dc7e4 to ea6ab02 Compare November 20, 2024 04:29

// the below can be both ciphertext or plaintext depending on the direction
// in => N 32-bit words => N 4 byte words
signal input plainText[N][32];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be preferable to have this take in bytes instead of bits. But maybe its not a big deal at all.

Copy link
Contributor Author

@0xJepsen 0xJepsen Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes i understand. Doing so is not as straight forward as we would like as the 32 bit words are little endian encoded. I did some work to start on this but will make an issue.

Copy link
Contributor

@Autoparallel Autoparallel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, in my opinion this can be merged so we can move along, but I honestly feel like this could be made quite a bit cleaner and clearer.

For one, I think it would probably serve us to have ChaCha20 take in bytes, not bits. Would be as easy as calling ByteToBits or ToBits(8) or whatever the template is. This makes life easier on the Rust side. It's not a big deal either way I suppose, but this just changes the API in an unexpected way, in my opinion.

Second, the way the full tests were laid out is, bizarre. If I was being stricter here, I'd ask you to redo it in the following way:

  1. Leave the NIVC_FULL and NIVC_FULL_2 tests as is, but rename them to NIVC_FULL_AES and NIVC_FULL_2_AES.
  2. Create two tests NIVC_FULL_CHACHA and NIVC_FULL_2_CHACHA.
  3. I think we should be testing these circuits in the same way we tested AES-GCTR here. The first NIVC_FULL folds a single 16 byte chunk at a time, NIVC_FULL folds 32 bytes at a time. You could mimic this with ChaCha by having NIVC_FULL_CHACHA run with all 320 bytes at once. Then NIVC_FULL_CHACHA_2 could do 160 bytes at once. This tests that the parameter for how many 32bit words to fold at once works with our circuit chain. It almost certainly does, but why not just test it that way?

Please consider taking this feedback and integrating it before you merge this. If not, then make issues at least, please!

circuits/test/full/full.test.ts Show resolved Hide resolved
@0xJepsen 0xJepsen changed the title feat: foldable chacha20 feat: chacha20 Nov 22, 2024
@0xJepsen 0xJepsen merged commit cabfa34 into main Nov 22, 2024
3 checks passed
@lonerapier lonerapier deleted the revert-50-revert-49-chacha20 branch November 22, 2024 05:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance ⚡️ This will not be worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: foldable ChaCha20 circuit
2 participants